﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>winjstk-composemailasync</title>

	<!-- WinJS references -->
	<link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
	<script src="//Microsoft.WinJS.2.0/js/base.js"></script>
	<script src="//Microsoft.WinJS.2.0/js/ui.js"></script>

	<link href="winjstk-composemailasync.css" rel="stylesheet" />
	<script src="winjstk-composemailasync.js"></script>
</head>
<body>
	<div class="description-page fragment">
		<header aria-label="Header content" role="banner">
			<button class="win-backbutton" aria-label="Back" disabled type="button"></button>
			<h1 class="titlearea win-type-ellipsis">
				<span class="pagetitle">WinJSTK.composeMailAsync()</span>
			</h1>
		</header>

		<section aria-label="Main content" role="main">
			<p>
				The WinJS Toolkit provides the <strong>WinJSTK.composeMailAsync</strong> function that you can use to launch the default mailer application 
				and compose a new mail message with the specified To, Subject and Body content.
			</p>
			<p>
				NOTE: The user must explicitly send the e-mail in the default e-mail application, you cannot send the mail automatically.
			</p>
			<p>
				NOTE: Your application must be visible to the user when you call this function!
			</p>
			
			<h2>Usage</h2>
			
			<h3>Parameters</h3>
			<p>
				<strong>to</strong> (String): The e-mail address of the recipient of the e-mail.<br/>
				<strong>subject</strong> (String): The subject of the e-mail. <br/>
				<strong>body</strong> (String): The text of the e-mail body.
			</p>
			
			<h3>Returns</h3>
			<p>
				A WinJS.Promise object with a Boolean value that is true if the mail is composed successfully, otherwise false.
			</p>

			<h3>Example</h3>
			<pre>
WinJSTK.composeMailAsync( 'support@example.com', 'Question', 'Dear Support, my problem is...' );
			</pre>

			
			<h2>Live demo</h2>
			
			<p>
				Click this button to create a new e-mail message:
				<button id="btn">Compose e-mail</button>
				<span id="result"></span>
			</p>
			
			<h2>Live demo source code</h2>
			
			<h3>The HTML page</h3>
<pre>
&lt;button id="btn"&gt;Compose e-mail&lt;/button&gt;
&lt;span id="result"&gt;&lt;/span&gt;
</pre>
			
			<h3>The JavaScript code</h3>
<pre>
var sp = document.getElementById( 'result' );
var btn = document.getElementById( 'btn' );
btn.onclick = function() {
	sp.innerHTML = 'You clicked the button, your mail application is now launched...';
	WinJSTK.composeMailAsync( 'balassy@aut.bme.hu', 'WinJS Toolkit feedback', 'I love the componseMailAsync function in the WinJS Toolkit!' ).done( function( success ) {
		sp.innerHTML = success ? 'The mail message is composed successfully.' : 'Composing the mail message failed';
	} );
};
</pre>

		</section>
	</div>
</body>
</html>
